package com.mine.common.core.constants;

import javax.swing.*;
import java.awt.*;
import java.time.LocalDateTime;

/**
 * 标签，图像标签
 *
 * @author jalasmart
 * 2024/3/18 11:38
 */
public interface Images {
    /**
     * 宽 30 ， 高 30
     */
    int WIDTH_30 = 30, HEIGHT_30 = 30;

    ImageIcon MIN_WIN_A_30_30 = new ImageIcon("最小化") {{
        this.setImage(Toolkit.getDefaultToolkit().getImage("src/main/resources/img/common/min-win.png"));
        this.setImage(this.getImage().getScaledInstance(30, 30, Image.SCALE_SMOOTH));
    }}, MIN_WIN_B_30_30 = new ImageIcon("最小化") {{
        this.setImage(Toolkit.getDefaultToolkit().getImage("src/main/resources/img/common/min-win-1.png"));
        this.setImage(this.getImage().getScaledInstance(30, 30, Image.SCALE_SMOOTH));
    }};

    ImageIcon CLOSE_A_30_30 = new ImageIcon("关闭") {{
        this.setImage(Toolkit.getDefaultToolkit().getImage("src/main/resources/img/close-2.png"));
        this.setImage(this.getImage().getScaledInstance(30, 30, Image.SCALE_SMOOTH));
    }}, CLOSE_B_30_30 = new ImageIcon("关闭") {{
        this.setImage(Toolkit.getDefaultToolkit().getImage("src/main/resources/img/close-3.png"));
        this.setImage(this.getImage().getScaledInstance(30, 30, Image.SCALE_SMOOTH));
    }};

    ImageIcon USERNAME_30_30 = new ImageIcon() {{
        this.setImage(Toolkit.getDefaultToolkit().getImage("src/main/resources/img/login/username/user.png"));
        this.setImage(this.getImage().getScaledInstance(WIDTH_30, HEIGHT_30, Image.SCALE_SMOOTH));
    }}, PWD_KEY_30_30 = new ImageIcon() {{
        this.setImage(Toolkit.getDefaultToolkit().getImage("src/main/resources/img/login/password/key.png"));
        this.setImage(this.getImage().getScaledInstance(WIDTH_30, HEIGHT_30, Image.SCALE_SMOOTH));
    }}, PWD_LOCK_30_30 = new ImageIcon() {{
        this.setImage(Toolkit.getDefaultToolkit().getImage("src/main/resources/img/login/password/lock-2.png"));
        this.setImage(this.getImage().getScaledInstance(WIDTH_30, HEIGHT_30, Image.SCALE_SMOOTH));
    }}, PWD_UNLOCK_30_30 = new ImageIcon() {{
        this.setImage(Toolkit.getDefaultToolkit().getImage("src/main/resources/img/login/password/unlock.png"));
        this.setImage(this.getImage().getScaledInstance(WIDTH_30, HEIGHT_30, Image.SCALE_SMOOTH));
    }};

    ImageIcon EYE_SHOW_30_30 = new ImageIcon() {{
        this.setImage(Toolkit.getDefaultToolkit().getImage("src/main/resources/img/login/password/eye/show-1.png"));
        this.setImage(this.getImage().getScaledInstance(WIDTH_30, HEIGHT_30, Image.SCALE_SMOOTH));
    }}, EYE_HIDDEN_30_30 = new ImageIcon() {{
        this.setImage(Toolkit.getDefaultToolkit().getImage("src/main/resources/img/login/password/eye/hidden.png"));
        this.setImage(this.getImage().getScaledInstance(WIDTH_30, HEIGHT_30, Image.SCALE_SMOOTH));
    }};

    ImageIcon LOGIN_HOUR_500_150_JPG = new ImageIcon() {
        {
            this.setImage(Toolkit.getDefaultToolkit().getImage("src/main/resources/img/login/datetime/hour/" + findImageIconByNow() + ".jpg"));
            //设置图片在窗体中显示的宽度、高度
            this.setImage(this.getImage().getScaledInstance(500, 150, Image.SCALE_SMOOTH));
        }

        private int findImageIconByNow() {
            int hour = LocalDateTime.now().getHour();
            switch (hour) {
                case 23:
                case 0:
                    return 1;
                case 1:
                case 2:
                    return 2;
                case 3:
                case 4:
                    return 3;
                case 5:
                case 6:
                    return 4;
                case 7:
                case 8:
                    return 5;
                case 9:
                case 10:
                    return 6;
                case 11:
                case 12:
                    return 7;
                case 13:
                case 14:
                    return 8;
                case 15:
                case 16:
                    return 9;
                case 17:
                case 18:
                    return 10;
                case 19:
                case 20:
                    return 11;
                case 21:
                case 22:
                    return 12;
            }
            return 0;
        }
    };

    ImageIcon LOGIN_WEEK_500_150_JPG = new ImageIcon() {
        {
            this.setImage(Toolkit.getDefaultToolkit().getImage("src/main/resources/img/login/datetime/week/" + findImageIconByNow() + ".jpg"));
            //设置图片在窗体中显示的宽度、高度
            this.setImage(this.getImage().getScaledInstance(500, 150, Image.SCALE_SMOOTH));
        }

        private int findImageIconByNow() {
            return LocalDateTime.now().getDayOfWeek().getValue();
        }
    };
}
